import * as GUI from '@babylonjs/gui';
export class Label extends GUI.Rectangle {
    private textBlock: GUI.TextBlock = new GUI.TextBlock();
    private _advancedTexture?: GUI.AdvancedDynamicTexture;
    private _raduis: number = 10;
    constructor(name: string, text: string) {
        super(name);
        this.textBlock = new GUI.TextBlock();
        this.textBlock.horizontalAlignment = 0;
        this.textBlock.verticalAlignment = 0;
        this.text = text;
        this.background = "#333";
        this.addControl(this.textBlock);
        this.cornerRadius = this._raduis;
    }

    public get text() {
        return this.textBlock.text;
    }

    public set text(value: string) {
        this.width = value.length * this.textBlock.fontSizeInPixels 
            + this.textBlock.paddingLeftInPixels 
            + this.textBlock.paddingRightInPixels + 'px';
        this.height = this.textBlock.fontSizeInPixels 
            + this.textBlock.paddingTopInPixels
            + this.textBlock.paddingBottomInPixels + 'px';
        if(this.heightInPixels < this.textBlock.fontSizeInPixels + 6) {
            this.height = this.textBlock.fontSizeInPixels + 6 + 'px';
        }
        this.textBlock.horizontalAlignment = 0;
        this.textBlock.verticalAlignment = 0;
        this.textBlock.text = value;
    }

    public get fontFamily() {
        return this.textBlock.fontFamily;
    }

    public set fontFamily(value: string) {
        this.textBlock.fontFamily = value;
    }

    public get fontSize() {
        return this.textBlock.fontSize;
    }

    public set fontSize(value: string | number) {
        this.textBlock.fontSize = value;
    }

    public get fontColor() {
        return this.textBlock.color;
    }

    public set fontColor(value: string) {
        this.textBlock.color = value;
    }

    public get verticalAlignment() {
        return super.verticalAlignment;
    }

    public set verticalAlignment(value: number) {
        super.verticalAlignment = value;
    }

    public get horizontalAlignment() {
        return super.horizontalAlignment;
    }

    public set horizontalAlignment(value: number) {
        super.horizontalAlignment = value;
    }
}